var algorithmApi = (function(){
    function quickSort(arr,low,high){
        if (low < high){
            let index = getIndex(arr,low,high);
            quickSort(arr,low,index-1);
            quickSort(arr,index+1,high);
        }
    };
    function getIndex(arr,low,high){
        //基准数据
        let tmp = arr[low];
        while (low < high){
            while(low < high && arr[high] > tmp){ high--}; //感觉这要加一个break的跳出条件
            arr[low] =  arr[high];
            while(low < high && arr[low] < tmp){ low++}; //感觉这个地方也要加一个break的跳出条件
            arr[high] = arr[low];
        }
        arr[low] = tmp;
        return low;
    };
    function selectionSort(arr){
        var len = arr.length;
        var minIndex,temp;
        for (var i = 0; i < len -1; i++){
            minIndex = i;
            for (var j = i + 1; j < len; j++){
                if (arr[j] < arr[minIndex]){
                    minIndex = j;
                }
                temp = arr[i];
                arr[i] = arr[minIndex];
                a[minIndex] = temp;
            }
        }
    }
    function bubblingSort(arr){
        for (var i = 0 ; i < arr.length;i++){
            for (var j = 0 ; j < arr.length - i - 1; j++){
                if (arr[j] > arr[i]){
                    var temp = arr[j];
                    arr[j] = arr[j+1];
                    arr[j+1] = temp;
                }
            }
        }
    }
    return {
        //快速
        quickSortMethod(arr){
            quickSort(arr,0,arr.length);
        },
        //选择
        selectionSortMethod(arr){
            selectionSort(arr);
        },
        bubblingSortMethod(arr){
            bubblingSort(arr);
        }
    };
})();
module.exports = {
    algorithmApi : algorithmApi
}